if [ $# -ne 1 ]
then
    echo "paramer IS EMPTY or INVALID"
    echo "0: single deploy; 1: cluster deploy"
    echo "return..."

    exit 1
fi

if [ $1 -eq 0 ]; then
    echo "single deloy ETCD"
    /home/lorry/cn_shell/software/etcd-v3.5.11-linux-amd64/etcd \
    --data-dir=/home/lorry/cn_shell/software/etcd-v3.5.11-linux-amd64/data.etcd-01 \
    --name etcd-01 \
    --initial-advertise-peer-urls http://192.168.1.165:2380 \
    --listen-peer-urls http://192.168.1.165:2380 \
    --advertise-client-urls https://192.168.1.165:2379 \
    --listen-client-urls https://192.168.1.165:2379 \
    --trusted-ca-file=/home/lorry/cn_shell/cfssl/ca.pem \
    --cert-file=/home/lorry/cn_shell/cfssl/server.pem \
    --key-file=/home/lorry/cn_shell/cfssl/server-key.pem
    # --client-cert-auth \
    # --trusted-ca-file=/home/lorry/cn_shell/software/etcd-v3.5.11-linux-amd64/pki/etcd/ca.crt \
    # --cert-file=/home/lorry/cn_shell/software/etcd-v3.5.11-linux-amd64/pki/apiserver-etcd-client.crt \
    # --key-file=/home/lorry/cn_shell/software/etcd-v3.5.11-linux-amd64/pki/apiserver-etcd-client.key
else
    echo "cluster deploy ETCD"
    /home/lorry/cn_shell/software/etcd-v3.5.11-linux-amd64/etcd \
    --data-dir=/home/lorry/cn_shell/software/etcd-v3.5.11-linux-amd64/data.etcd-01 \
    --name etcd-01 \
    --initial-advertise-peer-urls http://192.168.1.165:2380 \
    --listen-peer-urls http://192.168.1.165:2380 \
    --advertise-client-urls https://192.168.1.165:2379 \
    --listen-client-urls https://192.168.1.165:2379 \
    --client-cert-auth \
    --trusted-ca-file=/home/lorry/cn_shell/software/etcd-v3.5.11-linux-amd64/pki/etcd/ca.crt \
    --cert-file=/home/lorry/cn_shell/software/etcd-v3.5.11-linux-amd64/pki/apiserver-etcd-client.crt \
    --key-file=/home/lorry/cn_shell/software/etcd-v3.5.11-linux-amd64/pki/apiserver-etcd-client.key \
    --initial-cluster-state new \
    --initial-cluster-token token-01 \
    --initial-cluster CLUSTER=etcd-01=http://cn1:2380,etcd-02=http://cn2:2380,etcd-03=http://cn3:2380
fi